package com.huoyun.base.dao;

import java.util.List;

import com.huoyun.base.bean.NodeInfo;

public class NodeInfoDaoImpl extends BaseDaoImpl<NodeInfo> implements
		NodeInfoDao {

	@Override
	public int saveNodeInfo(final NodeInfo nodeInfo) {
		this.sqlSessionTemplate.insert(
				"com.huoyun.base.dao.NodeInfoDaoMapper.saveNodeInfo", nodeInfo);
		return nodeInfo.getId();
	}

	@Override
	public void update(final NodeInfo nodeInfo) {
		this.sqlSessionTemplate.update(
				"com.huoyun.base.dao.NodeInfoDaoMapper.update", nodeInfo);
	}

	@Override
	public List<NodeInfo> getNodeInfosByParentId(final int parentId) {
		return this.sqlSessionTemplate.selectList(
				"com.huoyun.base.dao.NodeInfoDaoMapper.getNodeInfosByParentId",
				parentId);
	}

	@Override
	public NodeInfo getNodeInfoById(final int nodeId) {
		return this.sqlSessionTemplate
				.selectOne(
						"com.huoyun.base.dao.NodeInfoDaoMapper.getNodeInfoById",
						nodeId);
	}

	@Override
	public void delete(final int nodeId) {
		this.sqlSessionTemplate.delete(
				"com.huoyun.base.dao.NodeInfoDaoMapper.delete", nodeId);
	}

	@Override
	public List<NodeInfo> getTopNodesByMode(final String modeName) {
		return this.sqlSessionTemplate.selectList(
				"com.huoyun.base.dao.NodeInfoDaoMapper.getTopNodesByMode",
				modeName);
	}

	@Override
	public List<NodeInfo> getAllNodeInfos() {
		return this.sqlSessionTemplate
				.selectList("com.huoyun.base.dao.NodeInfoDaoMapper.getAllNodeInfos");
	}
}
